﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ITProject.Domain.Entities;

namespace ITProject.WebUI.Models.Project
{
    public class ProjectTeamViewModel
    {
        public string Name { get; set; }
        public string Description { get; set; }
        public string Leader { get; set; }
        public string[] TeamUsers { get; set; }
        public string DateOfCreate { get; set; }

        public static IEnumerable<ProjectTeamViewModel> Convert(Team[] teams, string[] leaders, User[][] users)
        {
            ProjectTeamViewModel[] listVM = new ProjectTeamViewModel[teams.Length];
            for (int i = 0; i < teams.Length; i++)
            {
                listVM[i] = new ProjectTeamViewModel();
                listVM[i].Name = teams[i].Name;
                listVM[i].Description = teams[i].Description;
                listVM[i].DateOfCreate = teams[i].DateOfCreate.ToLongDateString();
                listVM[i].Leader = leaders[i];
                listVM[i].TeamUsers=new string[users[i].Length];
                for (int j = 0; j < users[i].Length; j++)
                    listVM[i].TeamUsers[j] = users[i][j].Login;
            }
            return listVM;
        }
    }
}